{extend name='table'}

{block name="button"}
<!--{if auth("remove")}-->
<button data-table-id="OplogTable" data-modal='{:url("add")}'
  class='layui-btn layui-btn-sm layui-btn-primary'>{:lang('添加')}</button>
<!--{/if}-->

{/block}
{block name="content"}
<div class="layui-tab layui-tab-card">
<ul class="layui-tab-title">
  {foreach ['0'=>lang('出库'),'1'=>lang('入库')] as $k=>$v}{if isset($type) and $type eq $k}
  <li data-open="{:url('logs')}?type={$k}&goods_id={$goods_id}" class="layui-this">{$v}</li>
  {else}
  <li data-open="{:url('logs')}?type={$k}&goods_id={$goods_id}">{$v}</li>
  {/if}{/foreach}
</ul>
<div class="layui-tab-content">
  <table id="OplogTable" data-url="{:request()->url()}" data-target-search="form.form-search"></table>
</div>
</div>
{/block}

{block name='script'}
<script>
  $(function () {
    $('#OplogTable').layTable({
      even: true, height: 'full',
      sort: { field: 'id', type: 'desc' },
      cols: [[
        { field: 'create_date', width: 150, title: '操作时间' },
        {
          field: 'type', title: '属性', minWidth: 120, align: 'center', templet: function (d) {
            if (d.type == 1) return '<span class="layui-badge  layui-bg-green">入库</span>';
            else return '<span class="layui-badge  layui-bg-blue">出库</span>';
          }
        },
        {
          field: 'type', title: '件数', minWidth: 120, align: 'center', templet: function (d) {
            if (d.type == 1) return '<span class="layui-badge  layui-bg-green">+'+d.box_num +'</span>';
            else return '<span class="layui-badge  layui-bg-blue">-' + d.box_num +'</span>';
          }
        },
        { field: 'num', width: 120, title: '重量', align: 'center' },
        { field: 'operator', width: 120, title: '经手人', align: 'center' },
        { field: 'recipient', width: 120, title: '接收人', align: 'center' },
        { field: 'note', width: 120, title: '备注', align: 'center' },
        { title: '操作', align: 'center', toolbar: '#toolbar' }
      ]]
    });
  });
</script>

<script type="text/html" id="toolbar">
 
<!--{if auth("edit")}-->
<a class="layui-btn layui-btn-sm" data-event-dbclick data-title="{:lang('编辑')}"
  data-modal='{:url("edit")}?id={{d.id}}'>{:lang('编辑')}</a>
<!--{/if}-->
<!--{if auth("remove")}-->
<a class="layui-btn layui-btn-sm layui-btn-danger" data-confirm="{:lang('确定要永久删除吗？')}" data-action="{:url('remove')}"
  data-value="id#{{d.id}}">{:lang('删除')}</a>
<!--{/if}-->
</script>
{/block}